//
//  LGBloodPressureHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/3/6.
//

#import "LGCancerMonitorHeader.h"


#define leftMargin   viewPix(58)
#define itemWidth    (Screen_W-viewPix(32)-leftMargin-viewPix(10))// viewPix(90)

@interface LGCancerMonitorHeader()
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *bottomView;
/**   */
@property (nonatomic , strong)UILabel *contentLabel;

@end

@implementation LGCancerMonitorHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.clipsToBounds = YES;
        self.backgroundColor = [UIColor clearColor];
        [self addSubview:self.baseView];
        [self.baseView addSubview:self.dateLabel];
        [self.baseView addSubview:self.bottomView];
        [self.baseView addSubview:self.contentLabel];
        [self.baseView addSubview:self.openBtn];
        
        [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(viewPix(7));
            make.left.bottom.equalTo(self).offset(viewPix(16));
            make.right.equalTo(self).offset(-viewPix(16));
        }];
        
        [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.baseView).offset(viewPix(38));
            make.left.bottom.right.equalTo(self.baseView);
        }];
        [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.baseView).offset(leftMargin);
            make.top.equalTo(self.baseView).offset(viewPix(46));
            make.width.equalTo(@(itemWidth));
            make.height.equalTo(@(viewPix(22)));
        }];
        [self.openBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.left.right.equalTo(self.baseView);
            make.height.equalTo(@(viewPix(38)));
        }];
    }
    return self;
}

-(void)setType:(NSString *)type{
    _type = type;
    if ([type isEqualToString:@"temperature"]) {
        //体温
        self.contentLabel.text = @"体温℃";
        
    }else if ([type isEqualToString:@"oxygen"]){
        //血氧
        self.contentLabel.text = @"血氧%";
        
    }else{
        //体重
        self.contentLabel.text = @"体重kg";
    }
}


-(UIView *)baseView{
    if(!_baseView){
        _baseView = [UIView shadowViewWithColor:@"#B2BDC7" offset:CGSizeMake(0, 2) opacity:0.15 radius:8];
        _baseView.backgroundColor = [UIColor whiteColor];
    }
    return _baseView;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(14) textAlignment:NSTextAlignmentLeft lines:1];
        _dateLabel.frame = CGRectMake(viewPix(12), 0, viewPix(150), viewPix(38));
    }
    return _dateLabel;
}


-(UIView *)bottomView{
    if(!_bottomView){
        _bottomView = [[UIView alloc] init];
        _bottomView.backgroundColor = [UIColor colorWithString:@"#F5FBFF"];
    }
    return _bottomView;
}

-(UILabel *)contentLabel{
    if(!_contentLabel){
        _contentLabel = [UILabel lableWithText:@"" colorString:@"#606266" textFont:LGFont(16) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _contentLabel;
}

-(UIButton *)openBtn{
    if(!_openBtn){
        _openBtn = [UIButton buttonWithImage:@"grayTipDown" selectImage:@"grayTipUp"];
        _openBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight;
        _openBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, viewPix(16));
    }
    return _openBtn;
}

@end
